var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function n() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((n.prototype = i.prototype), new n()));
      };
    })(),
  RecEquipmentView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.spaceTime = 0),
        WebSocketService.addListener({
          caller: t,
          code: 1300,
          method: t.onLoadHuiShouZhuangBeiData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1304,
          method: t.onLoadHuiShouFn,
        }),
        (t.list_recEquipment.vScrollBarSkin = ""),
        (t.list_recEquipment.selectEnable = !0),
        t.list_recEquipment.on(Laya.Event.CLICK, t, t.onDidListClickAction),
        (t.list_recEquipment.scrollBar.changeHandler = new Handler(
          t,
          t.onLoadMoreSendGoodsData
        )),
        t.btn_huishou_fanhui.on(Laya.Event.CLICK, t, t.onReqEquBackAction),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showRecEquView = function () {
        return (
          null == this.equVC && (this.equVC = new t()),
          WebSocketService.send({ c: 1300, d: { pageNum: 0 } }),
          (this.equVC.currentPage = 0),
          this.equVC
        );
      }),
      (t.prototype.onDidListClickAction = function (e) {
        if ("" != e.target.name && "btn_equiment_item" == e.target.name) {
          var t = this.list_recEquipment.selectedItem;
          NormalDialog.showNormalDialog(
            "您确定花费" + t.price + "银，回收" + t.name,
            this,
            this.onSureDidClick
          );
        }
      }),
      (t.prototype.onSureDidClick = function () {
        var e = this.list_recEquipment.selectedItem;
        WebSocketService.send({ c: 1304, d: { id: e.id } });
      }),
      (t.prototype.onLoadHuiShouZhuangBeiData = function (e) {
        if (0 == e.code) {
          if (this.currentPage >= 1) {
            if (0 == e.list.length) return void this.currentPage--;
            for (n = 0; n < e.list.length; n++) {
              var t = e.list[n];
              this.baoshiArr.push(t), (this.dataSource = []);
            }
          } else
            (this.baoshiArr = e.list),
              (this.dataSource = []),
              this.list_recEquipment.scrollTo(0);
          this.baoshiArr.length > 0 && (this.list_recEquipment.visible = !0),
            (this.isloading = !1);
          for (var i, n = 0; n < this.baoshiArr.length; n++) {
            var o = this.baoshiArr[n];
            (i = {
              label_equipment_name: { text: o.name },
              label_equipment_descr: { text: o.descr },
              label_equipment_lvl: { text: o.lvl + "级" },
              name: o.name,
              id: o.id,
              lvl: o.lvl,
              price: o.price,
            }),
              this.dataSource.push(i);
          }
          this.list_recEquipment.dataSource = this.dataSource;
        }
      }),
      (t.prototype.onLoadMoreSendGoodsData = function (e) {
        var t = e / this.list_recEquipment.scrollBar.max,
          i = new Date(),
          n = !1;
        if (
          (i.getTime() - this.spaceTime >= 3e3 && (n = !0),
          1 == t && 0 == this.isloading && n)
        )
          return (
            (this.isloading = !0),
            this.currentPage++,
            WebSocketService.send({
              c: 1300,
              d: { pageNum: this.currentPage },
            }),
            void (this.spaceTime = i.getTime())
          );
      }),
      (t.prototype.onLoadHuiShouFn = function (e) {
        ToastView.toastView(e.msg),
          WebSocketService.send({ c: 1300, d: { pageNum: this.currentPage } }),
          Laya.stage.event("GameMainView", "refreshMoney"),
          Laya.stage.event("HomePageView", "refreshMoney");
      }),
      (t.prototype.onReqEquBackAction = function () {
        this.removeSelf();
      }),
      t
    );
  })(ui.MarketController.RecEquipmentViewUI);
